<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var ktv = (function KTV() {
            // 为了保护lastPrice变量，将它放在函数内部
            var lastPrice = 1000;
            var total = 0;

            return {
                // 购物
                buy: function(price) {
                    total += price;
                },
                // 结账
                pay: function() {
                    if(total < lastPrice) {
                        console.log("请继续购物");
                    } else {
                        console.log("欢迎下次光临");
                    }
                },
                editLastPrice: function(vip, price) {
                    if(vip === '888') {
                        lastPrice = price;
                        console.log("现在的最低消费金额为：" + lastPrice);
                    } else {
                        console.log("权限不足");
                    }
                }
            }
        })();

    </script>
</body>
</html>